home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-MIPS / SOFTIRQ.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  2KB  |  89 lines

  1. /* $Id: softirq.h,v 1.5 1998/08/29 21:20:22 ralf Exp $
  2.  *
  3.  * This file is subject to the terms and conditions of the GNU General Public
  4.  * License.  See the file "COPYING" in the main directory of this archive
  5.  * for more details.
  6.  *
  7.  * Copyright (C) 1997, 1998 by Ralf Baechle
  8.  */
  9. #ifndef __ASM_MIPS_SOFTIRQ_H
  10. #define __ASM_MIPS_SOFTIRQ_H
  11.  
  12. /* The locking mechanism for base handlers, to prevent re-entrancy,
  13.  * is entirely private to an implementation, it should not be
  14.  * referenced at all outside of this file.
  15.  */
  16. extern atomic_t __mips_bh_counter;
  17.  
  18. extern unsigned int local_bh_count[NR_CPUS];
  19.  
  20. #define get_active_bhs()    (bh_mask & bh_active)
  21.  
  22. static inline void clear_active_bhs(unsigned long x)
  23. {
  24.     unsigned long temp;
  25.  
  26.     __asm__ __volatile__(
  27.         "1:\tll\t%0,%1\n\t"
  28.         "and\t%0,%2\n\t"
  29.         "sc\t%0,%1\n\t"
  30.         "beqz\t%0,1b"
  31.         :"=&r" (temp),
  32.          "=m" (bh_active)
  33.         :"Ir" (~x),
  34.          "m" (bh_active));
  35. }
  36.  
  37. extern inline void init_bh(int nr, void (*routine)(void))
  38. {
  39.     bh_base[nr] = routine;
  40.     bh_mask_count[nr] = 0;
  41.     bh_mask |= 1 << nr;
  42. }
  43.  
  44. extern inline void remove_bh(int nr)
  45. {
  46.     bh_base[nr] = NULL;
  47.     bh_mask &= ~(1 << nr);
  48. }
  49.  
  50. extern inline void mark_bh(int nr)
  51. {
  52.     set_bit(nr, &bh_active);
  53. }
  54.  
  55. /*
  56.  * These use a mask count to correctly handle
  57.  * nested disable/enable calls
  58.  */
  59. extern inline void disable_bh(int nr)
  60. {
  61.     bh_mask &= ~(1 << nr);
  62.     bh_mask_count[nr]++;
  63. }
  64.  
  65. extern inline void enable_bh(int nr)
  66. {
  67.     if (!--bh_mask_count[nr])
  68.         bh_mask |= 1 << nr;
  69. }
  70.  
  71. extern inline void start_bh_atomic(void)
  72. {
  73.     local_bh_count[smp_processor_id()]++;
  74.     barrier();
  75. }
  76.  
  77. extern inline void end_bh_atomic(void)
  78. {
  79.     barrier();
  80.     local_bh_count[smp_processor_id()]--;
  81. }
  82.  
  83. /* These are for the irq's testing the lock */
  84. #define softirq_trylock(cpu)    (local_bh_count[cpu] ? 0 : (local_bh_count[cpu] = 1))
  85. #define softirq_endlock(cpu)    (local_bh_count[cpu] = 0)
  86. #define synchronize_bh()    barrier()
  87.  
  88. #endif /* __ASM_MIPS_SOFTIRQ_H */
  89.